package gameElements;
import java.awt.Color;

/**
 * GBrick.java
 * 
 * Fredrik Wallenius and Peter Steiner 
 * DP08 - KTH - 2009
 *
 */
public class GBrick extends GBox{
	private int hitBox;
	
	public GBrick(double x, double y, Color color, double sizeX_, double sizeY_, Boolean causeBounce_, Boolean destroyable_, int hitBox_){
		super(x, y, color, sizeX_, sizeY_, causeBounce_, destroyable_);
		this.hitBox = hitBox_;
		setColor(this.hitBox);
	}
	
	/**
	 * Decrease brick hit box 
	 */
	public void hit(){
		if(hitBox != 0){
			hitBox--;
			setColor(hitBox);
		}
	}
	
	/**
	 * Is this brick ready to be terminated?
	 */
	public Boolean isDestroyable(){
		if(hitBox == 0){
			return true;
		}else{
			return false;		
		}
	}
	
	/**
	 * Set color after noOf hit points left for this brick
	 * 0-4, black, green, blue, orange, red.
	 * @param i
	 */
	public void setColor(int i){
		int hp = i;
		switch (hp) {
			case 0:
				color = Color.black;
				break;
			case 1:
				color = Color.green;
				break;
			case 2:
				color = Color.blue;
				break;
			case 3:
				color = Color.orange;
				break;
			case 4:
				color = Color.red;
				break;
	
			default:
				break;
		}
		
	}
	
	protected void constrain() {
		
	} 

}
